#include <bits/stdc++.h>
using namespace std;

int t, n;
int a[200002], cnt[1000002];

int main() {
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    scanf("%d", &t);
    while (t--) {
        scanf("%d", &n);
        memset(cnt, 0, sizeof(cnt));
        int p = 0;
        for (int i = 1; i <= n; i++) {
            scanf("%d", &a[i]);
            cnt[a[i]]++;
            p = max(a[i], p);
        }
        long long ans = 0;
        for (int i = 1; i <= p; i++) {
            if (cnt[i]) {
                ans += (cnt[i] / 2) * i;
            }
        }
        printf("%d", ans);
    }
    return 0;
}
